home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / VPOJAVA.DLL / SOURCE / BEANINFO < prev    next >
Text File  |  1998-12-10  |  2KB  |  64 lines

  1. import java.beans.*;
  2.  
  3. /*
  4. **    BeanInfo for JavaBean:
  5. */
  6. public class JavaBeanBeanInfo extends SimpleBeanInfo
  7. {
  8.     // getAdditionalBeanInfo method allows to return any number of additional
  9.     // BeanInfo objects which provide information about the Bean that this BeanInfo
  10.     // describes.
  11.     public BeanInfo[] getAdditionalBeanInfo()
  12.     {
  13.         try
  14.         {
  15.             BeanInfo[] bi = new BeanInfo[1];
  16.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  17.             return bi;
  18.         }
  19.         catch (IntrospectionException e) { throw new Error(e.toString());}
  20.     }
  21.  
  22.     // getIcon returns an image object which can be used by toolboxes, toolbars
  23.     // to represent this bean. Icon images are in GIF format.
  24.     public java.awt.Image getIcon(int iconKind)
  25.     {
  26.         if (iconKind == BeanInfo.ICON_COLOR_16x16 ||
  27.             iconKind == BeanInfo.ICON_MONO_16x16)
  28.         {
  29.             java.awt.Image img = loadImage("JavaBeanIcon16.gif");
  30.             return img;
  31.         }
  32.         if (iconKind == BeanInfo.ICON_COLOR_32x32 ||
  33.             iconKind == BeanInfo.ICON_MONO_32x32)
  34.         {
  35.             java.awt.Image img = loadImage("JavaBeanIcon32.gif");
  36.             return img;
  37.         }
  38.         return null;
  39.     }
  40.     
  41.     // getPropertyDescriptors returns an array of PropertyDescriptors which describe
  42.     // the editable properties of this bean.
  43.     public PropertyDescriptor[] getPropertyDescriptors()
  44.     {
  45.         try
  46.         {
  47.             PropertyDescriptor releasedColor = new PropertyDescriptor("releasedColor", beanClass);
  48.             PropertyDescriptor pressedColor = new PropertyDescriptor("pressedColor", beanClass);
  49.             releasedColor.setBound(true);
  50.             releasedColor.setDisplayName("Released Color");
  51.             pressedColor.setBound(true);
  52.             pressedColor.setDisplayName("Pressed Color");
  53.             
  54.             PropertyDescriptor rv[] = {releasedColor, pressedColor};
  55.             return rv;
  56.         }
  57.         catch (IntrospectionException e)
  58.         {
  59.             throw new Error(e.toString());
  60.         }
  61.     }
  62.     
  63.     private final static Class beanClass = JavaBean.class;
  64. }